package com.example.springbootsfzy.service.lishenao;

import com.example.springbootsfzy.domain.Consultants;
import com.example.springbootsfzy.mapper.ConsultantsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

////咨询师表
@Service
public class ConsultantsService {
    @Autowired
    private ConsultantsMapper consultantsMapper;
    ////操作人员:李深奥
    ///操作步骤:增删改查
    ///增加
    public int insert(Consultants record) {
        return consultantsMapper.insert(record);
    }

    ///删除
    public int deleteByPrimaryKey(Long id) {
        return consultantsMapper.deleteByPrimaryKey(id);
    }

    ///修改
    public int updateByPrimaryKey(Consultants record) {
        return consultantsMapper.updateByPrimaryKeySelective(record);
    }

    ///查询
    public Consultants selectByPrimaryKey(Long id) {
        return consultantsMapper.selectByPrimaryKey(id);
    }

    ///查询所有  (因分页需要,所以为单表查询,如果要查询七表联查,需使用指定id查单个)
    public PageInfo<Consultants> selectAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Consultants> users = consultantsMapper.selectAll();
        PageInfo<Consultants> pageInfo = new PageInfo<>(users);
        return pageInfo;
    }

    public List<Consultants> selectActive(Consultants consultants) {
        return consultantsMapper.selectActive(consultants);
    }

    public Consultants selectByAccountAndPassword(String username, String password){
        return consultantsMapper.selectByAccountAndPassword(username,password);
    }
}
